package com.itheima.setfor;

import java.util.Iterator;
import java.util.Set;
import java.util.TreeSet;

public class Test {
    public static void main(String[] args) {
        TreeSet<String> treeSet = new TreeSet<>();
        treeSet.add("刘备");
        treeSet.add("关羽");
        treeSet.add("张飞");
        treeSet.add("刘备");
        treeSet.add("张飞");
        System.out.println(treeSet.size());
        Iterator<String> iterator = treeSet.iterator();
        while (iterator.hasNext()){
            String s = iterator.next();
            System.out.print(s+" ");
        }
        System.out.println();
        for (String s : treeSet) {
            System.out.print(s+" ");
        }
        System.out.println();

    }
}
